
package com.craterhill.java.ems.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.craterhill.java.ems.common.beans.Role;
import com.craterhill.java.ems.dao.impl.AbstractDao;
import com.craterhill.java.ems.dao.utils.EMSResultSetExtractor;

public interface RoleDao extends EMSDao<Role> {

	public final String FIELD_LIST = "obj.role_id, obj.role_name, obj.role_short_name" + AbstractDao.MONITER_FIELDS;

	public final String FIND_ALL_ROLE = "select " + FIELD_LIST + " from roles obj";	

	public final class RoleExtractor extends EMSResultSetExtractor<Role> {

		@Override
		protected Role extractResultSetData(ResultSet resultSet) throws SQLException {
			Role role = new Role();
			role.setRoleId(resultSet.getInt(1));
			role.setRoleName(resultSet.getString(2));
			role.setRoleShortName(resultSet.getString(3));

			role.setCreatedBy(resultSet.getInt(4));
			role.setStatus(resultSet.getBoolean(5));
			role.setCreatedDate(resultSet.getDate(6));
			role.setModifiedDate(resultSet.getDate(7));
			return role;
		}
	}
}
